package define

/** 索引 */
type ErrorCodeType int

// 错误号
const (
	Success ErrorCodeType = 200

	Fail = 10000

	// 成功类请求
	LoginSuccess = 20001

	// 数据库或结果操作错误，这类错误不与入日志
	NameExist         = 30001
	NameNotExist      = 30002
	AccountExist      = 30003
	AccountNotExist   = 30004
	RoleExist         = 30005
	RoleNotExist      = 30006
	UserExist         = 30007
	UserNotExist      = 30008
	MenuNameExist     = 30009
	MenuNameNotExist  = 30010
	MenuTitleExist    = 30011
	MenuTitleNotExist = 30012
	MenuPidExist      = 30013
	MenuPidNotExist   = 30014
	MenuSeqExist      = 30015
	MenuSeqNotExist   = 30016
	MenuExist         = 30017
	MenuNotExist      = 30018
	IsParentNode      = 30019
	ParentIllegal     = 30020

	PwdErr            = 30021
	UserForbidden     = 30022
	UserExpire        = 30023
	DifferentLogin    = 30024
	PwdErrTimes       = 30025
	TimeErrStartEnd   = 30026
	ParseCtrlFail     = 30027
	RoleNameExist     = 30028
	RoleNameNotExist  = 30029
	RoleNameParseFail = 30030
	PlayerNotExist    = 30031
	SelectProp        = 30032
	FormatErrCronTime = 30033
	FetchNoticFail    = 30034
	NotcieEnded       = 30035
	EmailTypeErr      = 30036
	ParamErr          = 30037
	ParsePlayerFail   = 30038
	VipLevelErr       = 30039
	ParentNotExist    = 30040
	ParentIllegal2    = 30041

	// 数据库操作错误，这类错误写入日志
	DataOptFail       = 40001
	GameNodeDbErrLink = 40002
	NodeNameEmpty     = 40003
	NodeNameParseFail = 40004
	NodeServerEmpty   = 40005
	RecordNodFound    = 40006
	LinkServerFail    = 40007
	DbRoleNotExist    = 40008
	SystemBusy        = 40009

	// http请求
	BroadcastErr         = 40900
	ReqDelLoginNoticeErr = 40901

	// 项目错误类, 所有比这个号大的都写入日志
	TypeAssetErr = 60001
	UnKnow       = 60002

	// 请求类
	ReqParamsIllegal  = 70001
	PageOverPageLimit = 70002
	ReqInvokeFail     = 70003
	ReadReqRetFail    = 70004

	// 密钥类错误
	EncryptFail = 90001
)

var messages = map[ErrorCodeType]string{
	Success:           "成功",
	Fail:              "失败",
	UnKnow:            "未知错误",
	LoginSuccess:      "登录成功",
	ReqParamsIllegal:  "请求参数非法",
	ReqInvokeFail:     "请求调用失败",
	ReadReqRetFail:    "读取结果失败",
	PageOverPageLimit: "分页超过最大限制",
	NameExist:         "用户名已经存在",
	NameNotExist:      "用户名不存在",
	AccountExist:      "帐号名已经存在",
	AccountNotExist:   "帐号名不存在",
	RoleExist:         "角色已存在",
	RoleNotExist:      "角色不存在",
	RoleNameExist:     "角色名字已经存在",
	RoleNameNotExist:  "角色名字不能为空",
	UserExist:         "用户已存在",
	UserNotExist:      "用户不存在",
	PwdErr:            "用户密码输入错误",
	UserForbidden:     "用户被禁用，请联系管理员",
	UserExpire:        "用户已经过期",
	DifferentLogin:    "帐号在其他地方登录",
	PwdErrTimes:       "次密码连续出错",
	TimeErrStartEnd:   "开始结束时间错误",
	GameNodeDbErrLink: "节点数据库连接失败",
	NodeNameEmpty:     "节点名字不能为空",
	NodeNameParseFail: "解析节点名字失败",
	NodeServerEmpty:   "区服不能为空",
	RecordNodFound:    "记录未发现",
	LinkServerFail:    "区服连接失败",
	ParseCtrlFail:     "控制器解析失败",
	DbRoleNotExist: "	角色不存在",
	RoleNameParseFail: "解析玩家名字失败",
	PlayerNotExist:    "玩家不存在",
	SelectProp:        "请选择道具",
	FormatErrCronTime: "CronTimeStr格式不对",
	FetchNoticFail:    "获取公告失败",
	NotcieEnded:       "公告已结束：",
	EmailTypeErr:      "邮件类型错误",
	ParamErr:          "参数错误",
	ParsePlayerFail:   "解析玩家失败",
	VipLevelErr:       "vip等级参数错误",
	ParentNotExist:    "父节点不存在",

	BroadcastErr:         "广播错误",
	ReqDelLoginNoticeErr: "删除发送登录公告失败",

	DataOptFail:       "数据操作失败",
	EncryptFail:       "加密失败",
	MenuNameExist:     "标识已存在",
	MenuNameNotExist:  "标识不存在",
	MenuTitleExist:    "菜单标题已存在",
	MenuTitleNotExist: "菜单标题不存在",
	MenuPidExist:      "父ID已存在",
	MenuPidNotExist:   "父ID不存在",
	MenuSeqExist:      "序号已经存在",
	MenuSeqNotExist:   "序号不存在",
	MenuExist:         "菜单已存在",
	MenuNotExist:      "菜单不存在",
	IsParentNode:      "已经是父节点",
	ParentIllegal:     "非法父节点",
	ParentIllegal2:    "非法父节点2",
	TypeAssetErr:      "系统错误....",
	SystemBusy:        "系统繁忙，稍后再试....",
}

func GotMsg(mt ErrorCodeType) string {
	if _, ok := messages[mt]; ok {
		return messages[mt]
	}

	return messages[UnKnow]
}
